window.CESIUM_BASE_URL = '/cesium/';
import { Ion, Viewer, createWorldTerrain, createOsmBuildings, Cartesian3, Math,WebMapTileServiceImageryProvider } from "cesium";
import "cesium/Build/Cesium/Widgets/widgets.css";
import "../src/css/main.css"


// Your access token can be found at: https://cesium.com/ion/tokens.
// This is the default access token
Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWE1OWUxNy1mMWZiLTQzYjYtYTQ0OS1kMWFjYmFkNjc5YzciLCJpZCI6NTc3MzMsImlhdCI6MTYyNzg0NTE4Mn0.XcKpgANiY19MC4bdFUXMVEBToBmqS8kuYpUlxJHYZxk';
var tiandituTk='067998e486ea7ea61c91442ec719e8b3';
// 服务负载子域
var subdomains=['0','1','2','3','4','5','6','7'];
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Viewer('cesiumContainer', {
  // globe:false
  // terrainProvider: createWorldTerrain()
  animation:false,       //动画
  homeButton:true,       //home键
  geocoder:true,         //地址编码
  baseLayerPicker:false, //图层选择控件
  timeline:false,        //时间轴
  fullscreenButton:true, //全屏显示
  infoBox:true,         //点击要素之后浮窗
  sceneModePicker:true,  //投影方式  三维/二维
  navigationInstructionsInitiallyVisible:false, //导航指令
  navigationHelpButton:false,     //帮助信息
  selectionIndicator:false, // 选择
  imageryProvider: new WebMapTileServiceImageryProvider({
    //影像底图
    url: "http://t{s}.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk="+tiandituTk,
    subdomains: subdomains,
    layer: "tdtImgLayer",
    style: "default",
    format: "image/jpeg",
    tileMatrixSetID: "GoogleMapsCompatible",//使用谷歌的瓦片切片方式
    show: true
  })
});
viewer.imageryLayers.addImageryProvider(new WebMapTileServiceImageryProvider({   
  //影像注记
  url: "http://t{s}.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg&tk="+tiandituTk,
  subdomains: subdomains,
  layer: "tdtCiaLayer",
  style: "default",
  format: "image/jpeg",
  tileMatrixSetID: "GoogleMapsCompatible",
  show: true
}));
// Add Cesium OSM Buildings, a global 3D buildings layer.
// viewer.scene.primitives.add(createOsmBuildings());   

// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
  destination : Cartesian3.fromDegrees(117.005343, 36.667922, 40000000),
  orientation : {
    // heading : Math.toRadians(0.0),
    // pitch : Math.toRadians(-15.0),
  }
});